import java.util.*;

public class Main {

    public static void main(String[] args) {
//        int[] nums1 = {-1, 0, 1, 2, -1, -4};
//        int[] nums3 = {0,0,0};
//        System.out.println(SolutionTreeNumSum.threeSum(nums3));
        System.out.println(Main.isSubSequence("abcdefg","beg"));
    }

    public static boolean isSubSequence(String a, String b) {
        boolean result = false;
        Stack<Character> characterStack = new Stack<>();
        Set<Character> subSet = new HashSet<>();
        for (int i = 0; i < b.length(); i++) {
            subSet.add(b.charAt(i));
        }
        for (int i = 0; i < a.length(); i++) {
            if(subSet.contains(a.charAt(i)) && !characterStack.contains(a.charAt(i))){
                characterStack.push(a.charAt(i));
            }
        }

        return result;
    }
    /**
     * 第一题--两数之和
     * @param nums
     * @param target
     * @return
     */
    public int[] twoSum(int[] nums, int target) {
        Map<Integer,Integer> targetMap = new HashMap();
        for(int i =0 ;i < nums.length;i++){
            int targetValue = target - nums[i];
            if(targetMap.containsKey(targetValue)){
                return new int[]{targetMap.get(targetValue),i};
            }else{
                targetMap.put(nums[i],i);
            }
        }
        return new int[]{};
    }
}
/**
 第二题--两数相加
 */
class ListNode {
      int val;
      ListNode next;
      ListNode() {}
      ListNode(int val) { this.val = val; }
      ListNode(int val, ListNode next) { this.val = val; this.next = next; }
  }
class Solution2 {


}
